//
//  PhotoMainViewController.m
//  OAProject
//
//  Created by yhj on 2017/2/20.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "PhotoMainViewController.h"
#import "PhotoMainView.h"

@interface PhotoMainViewController ()

@property(nonatomic,strong)UIImage *image;

@property(nonatomic,strong)PhotoMainView *photoMainView;

@end

@implementation PhotoMainViewController

-(instancetype)initWithImage:(UIImage *)image
{
    self=[super init];
    if (self) {
        self.image=image;
    }
    return self;
}

// photoMainView
-(PhotoMainView *)photoMainView
{
    if (!_photoMainView) {
        _photoMainView=[PhotoMainView new];
        _photoMainView.backgroundColor=WhiteColor;
        ViewBorderRadius(_photoMainView,kmargin,1,ClearColor);
    }
    return _photoMainView;
}

-(void)backEvent
{
    [self.navigationController popViewControllerAnimated:NO];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title=@"上传照片";

    self.view.backgroundColor=MAIN_BACK_COLOR;

    [self initNavItem];

    [self.view addSubview:self.photoMainView];
    [_photoMainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kmargin);
        make.top.mas_equalTo(64);
        make.right.bottom.mas_equalTo(-kmargin);
    }];

    self.photoMainView.image=self.image;
    
}


-(void)initNavItem
{
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"提交" style:UIBarButtonItemStylePlain target:self action:@selector(submitEvent)];

    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(backEvent)];
}

-(void)submitEvent
{
    self.navigationItem.rightBarButtonItem.enabled=NO;
    NSLog(@"提交啦啦啦");
//    [API loginWithUserName:self.userNameTF.text password:self.passwordTF.text success:^(NSString *token) {
//
//        NSLog(@"token---%@",token);
//
//        [UserInfo sharedUserInfo].token=token;
//        [UserInfo sharedUserInfo].userName=self.userNameTF.text;
//
//        if (self.successBlock) {
//            self.successBlock();
//        }
//
//    } failure:^(NSInteger stateCode) {
//
//        NSLog(@"klkk----%ld",(long)stateCode);
//        
//    }];

//    [API uploadImageAndCotentWithImageData:self.imageData content:self.photoMainView.content success:^(BOOL is_success) {
//
//        self.navigationItem.rightBarButtonItem.enabled=YES;
//        NSLog(@"sdhdds可以通过");
//
//
//    } failure:^(NSInteger stateCode) {
//
//        NSLog(@"dsjjsddsjdsh---%ld",(long)stateCode);
//    }];

}


@end
